#include "SDL/SDL_thread.h"
#include <string.h>

static int kickstart(void *ptr);

class Thread
{
public:
	Thread() { m_name = NULL; m_thread = NULL; }

	void start()
	{
		m_thread = SDL_CreateThread(kickstart, this);
	}
	virtual void run()=0;

	void setName(const char *p_name)
	{
		if(m_name != NULL)
		{
			delete [] m_name;
		}

		m_name = new char[strlen(p_name)];
		strcpy(m_name, p_name);
	}
	char* getName()
	{
		return m_name;
	}

protected:
	SDL_Thread *m_thread;
	char *m_name;
};

static int kickstart(void *ptr)
{
	((Thread*)ptr)->run();

	return 0;
}

